package com.example.designPatterns.state.impl;

import com.example.designPatterns.state.*;

/**
 * @Title: WaitDeliverOrderState
 * @Description: TODO
 * @Date 2021/9/30 10:01
 */
public class ReceiveOrderState extends AbstractOrderState {


    @Override
    public OrderStateEnum orderState() {
        return OrderStateEnum.WAIT_DELIVER;
    }


    @Override
    public void execute(OrderStateContext context, Order order) {
        OrderStateEnum newState = OrderStateEnum.REFUNDING;
        //操作发货，并更新数据库
        order.setStatus(newState.getCode());
        //更新上下文状态
        context.setOrderState(OrderStateFactory.getState(newState));
        System.out.println("订单号：" + order.getOrderSn() + " 申请售后！状态流转至：" + newState.getDesc());
    }
}